import { Api } from './../../../providers/api-service';
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';

/**
 * 我的收藏
 */
@Component({
  selector: 'page-user-mycollect',
  templateUrl: 'user-mycollect.html',
})
export class UserMycollectPage {
  pageData = [{
    pageIndex: 1,
    forbidFinite: true,
    type: true,//刷新类型
    refresher: null,
    tiaozhanlist: [{
      Title: "wwwww",
      Pattern: "wwwwww",
      Classify: 0,
      HeadPortrait: 0,
      username: "wwwww",
      Integral: "wwwww"
    }]
  }, {
    forbidFinite: true,
    type: true,//刷新类型
    refresher: null,
    huatilist: []
  }, {
    forbidFinite: true,
    type: true,//刷新类型
    refresher: null,
    wenzhang_list: []
  }, {
    forbidFinite: true,
    type: true,//刷新类型
    refresher: null,
    study_list: []
  }];
  constructor(
    public navCtrl: NavController,
    public api: Api,
    public navParams: NavParams
  ) {
  }

  ionViewDidLoad() {
    console.log('我的收藏 UserMycollectPage');
    //this.getTiaoZhanList(1);
  }


  /**
   * 挑战列表
   */
  getTiaoZhanList(index) {
    let pageSize = 20;
    this.api.postBody("V1/GetMyCollection", {
      "ObjID": 10,
      "PageIndex": index,
      "PageSize": pageSize
    }).then(data => {
      console.log("挑战");
      if (data.Code == 0) {
        let list = data.Data.Dekaronlist.Items;
        if (list.length > 0) {

          if (this.pageData[0].type) { //初始化
            this.pageData[0]['tiaozhanlist'] = list;
          } else {
            this.pageData[0]['tiaozhanlist'] = this.pageData[0]['tiaozhanlist'].concat(list);
          }

          if (list.length == pageSize) {
            this.pageData[0]["pageIndex"]++;
          }

          if (list.length < pageSize) {
            this.pageData[0].forbidFinite = false;
          }
        }







      }

    })



  }
  act = [true, false, false, false];
  btn(value) {
    for (let i = 0; i < this.act.length; i++) {
      let isok = false;
      if (value == i) {
        isok = true;
      }
      this.act[i] = isok;
    }
  }

}
